/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package control;

import java.util.TimerTask;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author Douglas
 */
public class AnimacaoSprite extends TimerTask{

    private boolean adiantando = true;   
    private boolean movendo = false;
    private Sprite sprite;

    public AnimacaoSprite(Sprite sprite, boolean adiantando){
        this.sprite = sprite;
        this.adiantando = adiantando;
    }

    public void run() {
        if (!this.movendo) {
                return;
            }
            if (this.adiantando) {
                this.sprite.nextFrame();
            } else {
                this.sprite.prevFrame();
            }
    }

    public void adiantar() {
            this.adiantando = true;
            this.movendo = true;
        }

    public void voltar() {
            this.adiantando = false;
            this.movendo = true;
        }

    public void setMovendo(boolean movendo) {
        this.movendo = movendo;
    }
}
